{% extends "layouts/signed_out.html" %}

{% block title %}初始设置{% endblock %}

{% macro render_field_errors(field) -%}
  {% if field.errors %}
    {% for e in field.errors %}
      <p class="help-block">{{ e }}</p>
    {% endfor %}
  {% endif %}
{%- endmacro %}

{% macro render_field(field, help_block=None) -%}
  <div class="form-group {% if field.errors %}has-error{% endif %}">
    {{ field.label() }}
    {{ field(class='form-control') }}
    {% if help_block %}
        <p class="help-block">{{ help_block }}</p>
    {% endif %}
    {{ render_field_errors(field) }}
  </div>
{%- endmacro %}

{% block content %}
<div class="fixed-width-page">
  <div class="bg-white tiled">
    <h4 class="m-t-0">欢迎！</h4>
    <div>开始使用前，要进行一个快速初始化。</div>

    {% with messages = get_flashed_messages() %}
      {% if messages %}
        {% for message in messages %}
          <div class="alert alert-warning" role="alert">{{ message }}</div>
        {% endfor %}
      {% endif %}
    {% endwith %}

    <form role="form" method="post" name="create_account">
      <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
      <h4 class="m-t-25">单位信息：</h4>
      {{ render_field(form.org_slug) }}
      {{ render_field(form.org_name) }}

      <h4 class="m-t-25">系统管理员：</h4>
      {{ render_field(form.name) }}
      {{ render_field(form.email) }}
      {{ render_field(form.mobile) }}
      {% if show_sms_login != '' %}
      <div class="form-group">
        <label for="sms">短信验证码：</label>
        <input type="text" id="sms" name="sms">
        <button type="submit" name="smssend">发送手机验证码</button>
      </div>
      {% endif %}
      <div class="form-group">
        <label for="password">管理员密码：</label>
        <input type="text" id="password" name="password">
      </div>

      <button type="submit" style="height: 40px; font-size: 18px;" class="btn btn-primary btn-block m-t-25">保存设置</button>
    </form>
  </div>
</div>
{% endblock %}
